/**
 * author: Evan
 * date: Feb 23, 2009
 * Description: an interface to control a truck at a remote location using rmi
 * Modified: 
 * 	Feb 23, 2009 - initial set up - evan
 */
package white440.common;

import java.rmi.Remote;
import java.rmi.RemoteException;

import javax.swing.ImageIcon;

/**
 * An interface used to control a truck remotely
 * @author evan
 *
 */
public interface RemoteTruck extends Remote {
	
	/**
	 * the class that implements this interface should be bound in the rmi registry 
	 * under the name: RMINAME.
	 */
	public final static String RMINAME = "truck";
	
	
	/**Gets the current image seen by the specified web camera.
	 * The parameter camera determines which webcam to capture the image from.
	 * @param camera the web cam to get the image from. 0 is 'forward' 1 is 'rear'
	 * @return the current image seen by the webcam
	 * @throws RemoteException
	 */
	public ImageIcon getCameraImage(int camera)throws RemoteException;
	
//	/**
//	 * starts the video stream to the controller
//	 * @return true if the video stream started, false if it failed
//	 * @throws RemoteException if there is a communication problem with the truck
//	 */
//	public boolean startStreamingVideo() throws RemoteException;
//
//	//now using rtp with jmf	
//	/**
//	 * Used to get the location of the video feed from the forward camera on the truck.
//	 * The video feed is usually served in a separate thread on the truck jvm.
//	 * @return a MediaLocator pointing to the location on the web of the streaming video from the forward web-camera.
//	 * @throws RemoteException if there is a communication problem with the truck
//	 */
//	public MediaLocator getForwardCamera() throws RemoteException;
//	
//	/**
//	 * Used to get the location of the video feed from the rear facing camera on the truck.
//	 * The video feed is usually served in a separate thread on the truck jvm.
//	 * @return a MediaLocator pointing to the location on the web of the streaming video from the rear facing web-camera.
//	 * @throws RemoteException if there is a communication problem with the truck
//	 */
//	public MediaLocator getRearCamera() throws RemoteException;
	
	/**
	 * Sets the throttle from 0 to 100 percent.
	 * @param percent throttle to be set. percent must be between 0 and 100 inclusive. i.e. 0<=percent<=100
	 * @throws RemoteException if there is a communications problem with the truck
	 * @return successful: true if it was set, false if it was not
	 */
	public boolean setThrottle(int percent) throws RemoteException;
	
	/**
	 * Sets the heading of the truck as compared to its current orientation.
	 * degrees=0 corresponds to straight ahead, degrees=-90 is turn left 90 degrees, degrees=90 is turn right 90 degrees.
	 * The actual turning capabilities of the truck will probably be smaller.
	 * @param degrees to turn. Must satisfy: -90<=degrees<=90
	 * @throws RemoteException  if there is a communications problem with the truck
	 * @return successful: true if it was set, false if it was not 
	 */
	public boolean setDireciton(int degrees) throws RemoteException;
	
	/**
	 * called to check if you can currently communicate with the truck.
	 * if you can communicate this method returns true.
	 * if you can't communicate with the truck this method throws a RemoteException.
	 * @return true
	 * @throws RemoteException if there is a communications problem with the truck
	 */
	public boolean isConnected() throws RemoteException;
	
	/**
	 * Sets the truck's controller.
	 * Used by the truck to determine if it is connected to a controller.
	 * @param controller - the RemoteController that will control this truck
	 * @throws RemoteException if there is a communications problem with the truck
	 */
	public void setController(RemoteController controller) throws RemoteException;
}
